package com.collect.zambia.zhiHelper;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.Gravity;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;

import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectChangeListener;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.bigkoo.pickerview.view.TimePickerView;
import com.collect.zambia.R;
import com.collect.zambia.zhiGlobal.zhiAppSettings.ZHIProjectConstants;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class ZHIPickerDateHelper {

    /**
     * 日期选择器
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:41
     */
    public static TimePickerView showDatePicker(Context context, boolean showAfterInit, OnTimeSelectListener onTimeSelectListener) {

        TimePickerView pvTime = new TimePickerBuilder(context, onTimeSelectListener)
                .setType(new boolean[]{true, true, true, false, false, false})// 默认全部显示
                .setCancelText(" ")//取消按钮文字
                .setContentTextSize(18)//滚轮文字大小
                .setTitleSize(20)//标题文字大小
                .setTitleText("")//标题文字
                .setTitleBgColor(context.getResources().getColor(R.color.theme_color_0))
                .setTextColorCenter(context.getResources().getColor(R.color.theme_black_0))
                .setOutSideCancelable(true)//点击屏幕，点在控件外部范围时，是否取消显示
                .setTitleColor(context.getResources().getColor(R.color.theme_black_0))
                .setCancelColor(context.getResources().getColor(R.color.white))
                .setSubmitColor(context.getResources().getColor(R.color.white))
                .isDialog(true)//是否显示为对话框样式
                .build();

        Dialog mDialog = pvTime.getDialog();
        if (mDialog != null) {

            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT,
                    Gravity.BOTTOM);

            params.leftMargin = 0;
            params.rightMargin = 0;
            pvTime.getDialogContainerLayout().setLayoutParams(params);

            Window dialogWindow = mDialog.getWindow();
            if (dialogWindow != null) {
                dialogWindow.setWindowAnimations(com.bigkoo.pickerview.R.style.picker_view_slide_anim);//修改动画样式
                dialogWindow.setGravity(Gravity.BOTTOM);//改成Bottom,底部显示
                dialogWindow.setDimAmount(0.3f);
            }
        }

        if (showAfterInit) {
            pvTime.show();
        }

        return pvTime;
    }

    /**
     * 格式化日期
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:41
     */
    @SuppressLint("SimpleDateFormat")
    public static String getDateFormatString(Date date) {
        //可根据需要自行截取数据显示
        Log.d("getTime()", "choice date millis: " + date.getTime());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        return format.format(date);
    }

    /**
     * 条件选择器
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:41
     */
    public static OptionsPickerView showDataPicker(Context context, OnOptionsSelectListener onOptionsSelectListener) {

        OptionsPickerView pvOptions = new OptionsPickerBuilder(context, onOptionsSelectListener)
                .setTitleText("")
                .setContentTextSize(20)//设置滚轮文字大小
                .setDividerColor(Color.LTGRAY)//设置分割线的颜色
                .setSelectOptions(0)//默认选中项
                .setBgColor(Color.WHITE)
                .setTitleBgColor(context.getResources().getColor(R.color.theme_color_0))
                .setTitleColor(context.getResources().getColor(R.color.theme_black_0))
                .setCancelText(" ")
                .setCancelColor(context.getResources().getColor(R.color.white))
                .setSubmitColor(context.getResources().getColor(R.color.white))
                .setTextColorCenter(context.getResources().getColor(R.color.theme_color_0))
                .setOutSideCancelable(true)//点击屏幕，点在控件外部范围时，是否取消显示
                .isRestoreItem(true)//切换时是否还原，设置默认选中第一项。
                .isCenterLabel(false) //是否只显示中间选中项的label文字，false则每项item全部都带有label。
                .setOutSideColor(0x40000000) //设置外部遮罩颜色
                .setOptionsSelectChangeListener(new OnOptionsSelectChangeListener() {
                    @Override
                    public void onOptionsSelectChanged(int options1, int options2, int options3) {
                        String str = "options1: " + options1 + "\noptions2: " + options2 + "\noptions3: " + options3;
                    }
                })
                .build();

        return pvOptions;
    }

    /**
     * Marital Status 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getMaritalStatusDess() {
        ArrayList<String> list = new ArrayList<>();

        list.add("Married");
        list.add("Unmarried");
        list.add("Devorce");
        list.add("Widowhood");

        return list;
    }

    /**
     * Marital Status 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getMaritalStatuss() {
        ArrayList<String> list = new ArrayList<>();

        list.add("MARRIED");
        list.add("UNMARRIED");
        list.add("DIVORCE");
        list.add("WIDOWHOOD");

        return list;
    }


    /**
     * Highest Education 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getEducationDess() {
        ArrayList<String> list = new ArrayList<>();

        list.add("Primary");
        list.add("General Secondary");
        list.add("Senior Secondary");
        list.add("University Degree");
        list.add("Postgraduate");
        list.add("Doctoral Degree");
        list.add("Other");

        return list;
    }

    /**
     * Highest Education 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getEducations() {
        ArrayList<String> list = new ArrayList<>();

        list.add("PRIMARY");
        list.add("GENERAL_SECONDARY");
        list.add("SENIOR_SECONDARY");
        list.add("UNIVERSITY_DEGREE");
        list.add("POSTGRADUATE");
        list.add("DOCTORAL_DEGREE");
        list.add("OTHER");

        return list;
    }

    /**
     * Language 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getLanguages() {
        ArrayList<String> list = new ArrayList<>();

        list.add("English");
        list.add("Hindi");
        list.add("Marathi");
        list.add("Bengali");
        list.add("Telugu");
        list.add("Tamil");
        list.add("Gujarati");
        list.add("Kannada");
        list.add("Urdu");
        list.add("Malayalam");
        list.add("Odia");
        list.add("Punjabi");
        list.add("Assamese");

        return list;
    }

    /**
     * Religion 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getReligions() {
        ArrayList<String> list = new ArrayList<>();

        list.add("Hinduism");
        list.add("Islam");
        list.add("Christianity");
        list.add("Sikhism");
        list.add("Buddhism");
        list.add("Jainism");
        list.add("No religion");
        list.add("Other");

        return list;
    }

    /**
     * RelationShip 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getRelationShips() {
        ArrayList<String> list = new ArrayList<>();

        list.add("FATHER");
        list.add("MOTHER");
        list.add("SPOUSE");
        list.add("BROTHERS");
        list.add("SISTERS");

        return list;
    }

    /**
     * Employment type 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getEmploymentTypes() {
        ArrayList<String> list = new ArrayList<>();

        list.add("full-time salaried");
        list.add("part-time salaried");
        list.add("self-employed");
        list.add("no job");
        list.add("student");
        list.add("other");

        return list;
    }

    /**
     * Residence type 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getResidenceTypes() {
        ArrayList<String> list = new ArrayList<>();

        list.add("RENTED");
        list.add("OWNED");
        list.add("WITH RELATIVES");
        list.add("OFFICE PROVIDED");
        list.add("student");
        list.add("other");

        return list;
    }

    /**
     * Salary type 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getSalaryTypes() {
        ArrayList<String> list = new ArrayList<>();

        list.add(("below and " + ZHIProjectConstants.RS_FLAG + "15,000"));
        list.add((ZHIProjectConstants.RS_FLAG + "15,000" + "-" + ZHIProjectConstants.RS_FLAG + "25,000"));
        list.add((ZHIProjectConstants.RS_FLAG + "25,000" + "-" + ZHIProjectConstants.RS_FLAG + "35,000"));
        list.add((ZHIProjectConstants.RS_FLAG + "35,000" + "-" + ZHIProjectConstants.RS_FLAG + "45,000"));
        list.add((ZHIProjectConstants.RS_FLAG + "35,000" + " and above"));

        return list;
    }

    /**
     * Salary type 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getSalarys() {
        ArrayList<String> list = new ArrayList<>();

        list.add(("12000"));
        list.add(("17000"));
        list.add(("28000"));
        list.add(("40000"));
        list.add(("52000"));

        return list;
    }

    /**
     * Salary type 列表
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-11-04 13:54
     */
    public static ArrayList<String> getFeedbackCategorys() {
        ArrayList<String> list = new ArrayList<>();

        list.add(("Product Suggestion"));
        list.add(("Service Complaints"));
        list.add(("Program Error"));

        return list;
    }
}
